﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApp1
{
    /// <summary>
    /// Pane_1.xaml 的交互逻辑
    /// </summary>
    public partial class Pane_1 : Window
    {
        public Pane_1()
        {
            InitializeComponent();
        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var lb = sender as ListBox;
            switch (lb.Name)
            {
                case "lb1":
                    if (lb1.SelectedIndex == 0) wp1.Orientation = sp1.Orientation = Orientation.Horizontal;
                    else wp1.Orientation = sp1.Orientation = Orientation.Vertical;
                    break;
                case "lb2":
                    if (lb2.SelectedIndex == 0) wp1.HorizontalAlignment = sp1.HorizontalAlignment = HorizontalAlignment.Left;
                    else if (lb2.SelectedIndex == 1) wp1.HorizontalAlignment = sp1.HorizontalAlignment = HorizontalAlignment.Right;
                    else if (lb2.SelectedIndex == 2) wp1.HorizontalAlignment = sp1.HorizontalAlignment = HorizontalAlignment.Center;
                    else wp1.HorizontalAlignment = sp1.HorizontalAlignment = HorizontalAlignment.Stretch;
                    break;
                case "lb3":
                    if (lb3.SelectedIndex == 0) wp1.VerticalAlignment = sp1.VerticalAlignment = VerticalAlignment.Top;
                    else if (lb3.SelectedIndex == 1) wp1.VerticalAlignment = sp1.VerticalAlignment = VerticalAlignment.Bottom;
                    else if (lb3.SelectedIndex == 2) wp1.VerticalAlignment = sp1.VerticalAlignment = VerticalAlignment.Center;
                    else wp1.VerticalAlignment = sp1.VerticalAlignment = VerticalAlignment.Stretch;
                    break;
                default:
                    break;
            }
        }
    }
}
